package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.datascope.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ActivityMapper;
import com.ruoyi.system.domain.Activity;
import com.ruoyi.system.service.IActivityService;

/**
 * 活动信息管理表Service业务层处理
 * 
 * @author hyb
 * @date 2023-01-20
 */
@Service
public class ActivityServiceImpl implements IActivityService 
{
    @Autowired
    private ActivityMapper activityMapper;

    /**
     * 查询活动信息管理表
     * 
     * @param id 活动信息管理表主键
     * @return 活动信息管理表
     */
    @Override
    public Activity selectActivityById(Long id)
    {
        return activityMapper.selectActivityById(id);
    }

    /**
     * 查询活动信息管理表列表
     * 
     * @param activity 活动信息管理表
     * @return 活动信息管理表
     */

    @DataScope(userAlias = "a")
    @Override
    public List<Activity> selectActivityList(Activity activity)
    {
        return activityMapper.selectActivityList(activity);
    }

    /**
     * 新增活动信息管理表
     * 
     * @param activity 活动信息管理表
     * @return 结果
     */
    @Override
    public int insertActivity(Activity activity)
    {
        activity.setCreateTime(DateUtils.getNowDate());
        return activityMapper.insertActivity(activity);
    }

    /**
     * 修改活动信息管理表
     * 
     * @param activity 活动信息管理表
     * @return 结果
     */
    @Override
    public int updateActivity(Activity activity)
    {
        activity.setUpdateTime(DateUtils.getNowDate());
        return activityMapper.updateActivity(activity);
    }

    /**
     * 批量删除活动信息管理表
     * 
     * @param ids 需要删除的活动信息管理表主键
     * @return 结果
     */
    @DataScope(userAlias = "a")
    @Override
    public int deleteActivityByIds(Long[] ids)
    {
        return activityMapper.deleteActivityByIds(ids);
    }

    /**
     * 删除活动信息管理表信息
     * 
     * @param id 活动信息管理表主键
     * @return 结果
     */
    @Override
    public int deleteActivityById(Long id)
    {
        return activityMapper.deleteActivityById(id);
    }

    @DataScope(userAlias = "a")
    @Override
    public int countActivity(Activity activity ) {
        return activityMapper.countActivity(activity);
    }

    @DataScope(userAlias = "a")
    @Override
    public int countApproveLog(Activity activity) {
        Integer i = activityMapper.countApproveLog(activity);
        return i==null?0:i;
    }

    @Override
    public List<Activity> selectActivityByMaxHotCountAsc(Long number) {
        return activityMapper.selectActivityByMaxHotCountAsc(number);
    }


}
